package com.kgajowy.result;

import edu.pjwstk.jps.result.ISingleResult;
import edu.pjwstk.jps.result.IStructResult;

import java.util.ArrayList;
import java.util.List;

public class StructResult extends SingleResult implements IStructResult {

    ArrayList<ISingleResult> elements;
    
    public StructResult() {
        this.elements = new ArrayList<ISingleResult>();
    }
    
    public StructResult(ISingleResult... args) {
        this.elements = new ArrayList<ISingleResult>();
        for (ISingleResult arg : args) {
            elements.add(arg);
        }
    }
    
    public void add(ISingleResult res) {
        this.elements.add(res);
    }
    
    @Override
    public List<ISingleResult> elements() {
        return this.elements;
    }

    @Override
    public String stringme() {
        String result = "";
        int i = 0;
        result += "struct(";
        for ( ISingleResult item : elements ){
            if ( i > 0 ) { result += ", "; } //separator
            result += i + "=" + ((SingleResult)item).stringme();
            ++i;
        }
        result += ")";
        
        return result;
        
    }
    
    

}
